package aqr.model;

import java.util.Comparator;

public class Employee implements Comparable<Employee> {
	
	private int id;
	private String name;
	private String department;
	private int age;
	
	public Employee() {	}
	
	public Employee(int id, String name, String department, int age) {
		super();
		this.id = id;
		this.name = name;
		this.department = department;
		this.age = age;
	}

	public int compareTo(Employee e) {
		return this.name.compareTo(e.name) == 0 ? 
				(this.department.compareTo(e.department) == 0 ? 
						(this.age > e.age ? 1 : (this.age < e.age ? -1 : 0)
				) : this.department.compareTo(e.department)
			) : this.name.compareTo(e.name); 
	}
	
	public static Comparator<Employee> EmployeeComparator = new Comparator<Employee> () {
		public int compare(Employee e1, Employee e2) {
			return e1.name.compareTo(e2.name) == 0 ? 
					(e1.department.compareTo(e2.department) == 0 ? 
							(e1.age > e2.age ? 1 : (e1.age < e2.age ? -1 : 0)
					) : e1.department.compareTo(e2.department)
				) : e1.name.compareTo(e2.name); 
		}
	}; 
	
	public String toString() {
		return "ID: "+this.id+", Name: "+this.name+", Department: "+this.department+",  Age: "+this.age;
	}
	
}
